package com.naiterui.ehp.bs.recommend.handler;

import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;



/**
 * 包装drug类
 * @author YongYang
 * @since 1.0.0
 */
public class DrugWrapper implements Delayed {
    /**
     * 审核通过时间
     */
    private long endTime;

    /**
     * 药方Id
     */
    private long recommandId;

    public DrugWrapper(long recommandId, long endTime) {
        this.recommandId = recommandId;
        this.endTime = endTime;
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
    }

    public long getRecommandId() {
        return recommandId;
    }

    public void setRecommandId(long recommandId) {
        this.recommandId = recommandId;
    }

    @Override
    public long getDelay(TimeUnit unit) {
        long d = unit.convert(endTime - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
        return d;
    }

    @Override
    public int compareTo(Delayed o) {
        int result = 0;
        DrugWrapper that = (DrugWrapper) o;
        if (endTime < that.endTime) {
            result = -1;
        }
        if (endTime > that.endTime) {
            result = 1;
        }
        return result;
    }

}
